<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  </head>
  <body>
    <script>
      // 存储复杂数据类型
      let obj = {
        username: '小明',
        age: 17,
        address: '北京市',
      };
      // 设置数据
      localStorage.setItem('obj', JSON.stringify(obj));
      // 获取数据
      console.log(JSON.parse(localStorage.getItem('obj')));
    </script>
  </body>
</html>
